#include <stdio.h>
#include <string.h>
int main()
{
    FILE *fp = fopen("log.txt", "w");
    if (fp == NULL)
    {
        perror("fopen");
        return 1;
    }
    fprintf(fp, "%s\n", "linux so easy!"); // 向文件写入
    fclose(fp);
    FILE *p = fopen("log.txt", "r");
    if (p == NULL)
    {
        perror("fopen");
        return 1;
    }
    char buffer[64];
    while (fgets(buffer, sizeof(buffer) - 1, p) != NULL) 
    {
        buffer[strlen(buffer) - 1] = 0; 
        puts(buffer);
    }
    return 0;
}
